<?php

use yii\helpers\ArrayHelper;

$config = require Yii::getAlias('@common/config/main.php');

$globPaths = [
    '@common/modules/*/config/main.php', // 合并modules下面的主配置信息
    '@common/modules/*/config/console.php', // 合并modules下面的后台配置信息
];
foreach ($globPaths as $globPath)
{
    $files = glob(Yii::getAlias($globPath));
    foreach ($files as $file)
    {
        $config = ArrayHelper::merge(
            require $file,
            $config
        );
    }
}

$config = ArrayHelper::merge($config, [
    'id' => 'cms-console',
    'basePath' => CMS_ROOT . 'console' . DIRECTORY_SEPARATOR,
    'runtimePath' => CMS_ROOT . 'console' . DIRECTORY_SEPARATOR . 'runtime',
    'bootstrap' => ['log'],
    'controllerNamespace' => 'console\controllers',
    'components' => [
        'log' => [
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
    ],
    'params' => require(__DIR__ . '/params.php'),
]);

return $config;
